// 3487. 删除后的最大子数组元素和
// AC: https://leetcode.cn/problems/maximum-unique-subarray-sum-after-deletion/submissions/620711476/

class Solution {
public:
    int maxSum(vector<int>& nums) {
        int t=-100;
        set<int> s;
        for(auto x:nums){
            if(x>0)
                s.insert(x);
            else if(x>t){
                t=x;
            }
        }
        int sum=0;
        for(auto it=s.begin();it!=s.end();++it){
            sum+=*it;
        }
            return sum>0?sum:t;
        
    }
};